package com.example.interceptor.config;


import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 登录拦截器具体方法实现
 */
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("执行拦截器：preHandle 方法");
//        response.sendRedirect("login.html");
        request.getRequestDispatcher("/login.html").forward(request,response);
        return true; // 返回 true 表示拦截器验证通过，false 表示未通过
    }
}
